<?php

/**
 * HostDeck - Web Hosting Automation
 * http://code.google.com/p/hostdeck
 * --------------------------------------------
 * Last Modified:		March 9, 2012 @ 6:55 P.M.
 * Core Version:		1.0.0
 * Graph API Version:	1.0.0
 * Component Version:	1.0.0
 */
 
###
## Pre-Startup Code
###

### Define path to base directory ###
define("LINK", "./");

### Start a null session ###
session_start();

###
## Check for a session
###
if(!empty($_GET["callback"])) {
	if(
		(!empty($_SESSION["hdeck_user"])) &&
		(!empty($_SESSION["hdeck_pass"]))
	) {
		header("location: " . LINK . "verify.php?type=session&id=" . sha1($_SERVER["REMOTE_ADDR"]) . "&returnurl=/");
		exit();
	}
}

if(
	(!empty($_SESSION["hdeck_user"])) &&
	(!empty($_SESSION["hdeck_pass"]))
) {
	$loggedin = true;
}
else {
	$loggedin = false;
}

###
## Are we installed?
###
/**
REMOVE AFTER DEVELOPMENT!
if(
	(!is_file(LINK . "library/configuration.php")) ||
	(filesize(LINK . "library/configuration.php") == 0)
) {
	# We're not installed!
	header("location: " . LINK . "setup.php?type=install");
	exit();
}
**/

###
## Access the database
###
require LINK . "library/configuration.php";
$con = mysql_connect($dbhost, $dbuser, $dbpass) or header("location: " . LINK . "error.php?msg=Failed+to+connect+to+MySQL+server.");
mysql_select_db($dbname) or header("location: " . LINK . "error.php?msg=Unable+to+select+database.");

###
## Do the rest of the code
###
require LINK . "library/classes/class.settings.php";
$settings = new settings;

// Get Setting Variables
$eVar = array();
$eVar["name"] = $settings->getval($con, 1);

?>
<!DOCTYPE html>
<html>
<head>
	<title><?php echo $eVar["name"]["value"]; ?> // Client Portal</title>
	<link rel="stylesheet" type="text/css" media="all" href="./assets/css/bootstrap.css" />
	<style type="text/css">
		body {
			padding-top: 60px;
			padding-bottom: 40px;
		}
	</style>
	<link rel="stylesheet" type="text/css" media="all" href="./assets/css/bootstrap-responsive.css" />
</head>
<body>
<div class="navbar navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container">
			<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</a>
			<a class="brand" href="#"><?php echo $eVar["name"]["value"]; ?></a>
			<div class="nav-collapse">
				<ul class="nav">
					<li class="active"><a href="./">Home</a></li>
					<li class="divider-vertical"></li>
					<li><a href="./order.php">Order a Package</a></li>
					<li><a href="./client.php">Client Area</a></li>
				</ul>
				<?php if($loggedin) { ?>
					<p class="navbar-text pull-right">Logged in as <a href="#"><?php echo $_SESSION["hdeck_user"]; ?></a> (<a href="./logout.php">Logout</a>)</a></p>
				<?php } ?>
			</div><!--/.nav-collapse -->			
		</div>
	</div>
</div>
<div class="container">
	<div class="hero-unit">
		<h1>Welcome to the Client Area.</h1>
		<p>
			Welcome to the <?php echo $eVar["name"]["value"]; ?> Client Hub. From here, you can order a new package, log in to your client area, edit your existing hosting package, view or submit support tickets and log in to the servers.
		</p>
	</div>
	<div class="row">
		<div class="span4">
			<h2>Order a Package</h2>
			<p align="justify">
				Visit the Order Form to browse the Products & Services we offer. Existing customers can also purchase optional extras and addons here.
			</p>
			<p><a class="btn" href="./order.php">Order Now &raquo;</a></p>
		</div>
		<div class="span4">
			<h2>Manage Your Account</h2>
			<p align="justify">
				Already registered with us? If so, click the button below to login to our client area from where you can manage your account. You can view your package and submit tickets from there.
			</p>
			<p><a class="btn" href="./client.php">Log in to the Client Area &raquo;</a></p>
		</div>
		<div class="span4">
			<h2>Network Status</h2>
			<p>
				List, view and monitor our servers. You can view the latest server uptime reports, uptime percentile and service daemon statuses.
			</p>
			<p><a class="btn" href="./serverstatus.php">View Status &raquo;</a></p>
		</div>
	</div>
	
	<hr />
	
	<footer>
		&copy; <?php echo date("Y"); ?> <?php echo $eVar["name"]["value"]; ?> - Powered by <a href="http://code.google.com/p/hostdeck">HostDeck</a> Web Host Autmation
	</footer>
</body>
</html>